package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallNotice;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallNoticeMapper {
    @Delete({
        "delete from haogoumall_notice",
        "where notice_id = #{noticeId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer noticeId);

    @Insert({
        "insert into haogoumall_notice (notice_id, notice_title, ",
        "notice_content, notice_create_admin_id, ",
        "notice_add_time, notice_update_time, ",
        "notice_deleted)",
        "values (#{noticeId,jdbcType=INTEGER}, #{noticeTitle,jdbcType=VARCHAR}, ",
        "#{noticeContent,jdbcType=VARCHAR}, #{noticeCreateAdminId,jdbcType=INTEGER}, ",
        "#{noticeAddTime,jdbcType=TIMESTAMP}, #{noticeUpdateTime,jdbcType=TIMESTAMP}, ",
        "#{noticeDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallNotice record);

    @InsertProvider(type=HaogoumallNoticeSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallNotice record);

    @Select({
        "select",
        "notice_id, notice_title, notice_content, notice_create_admin_id, notice_add_time, ",
        "notice_update_time, notice_deleted",
        "from haogoumall_notice",
        "where notice_id = #{noticeId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="notice_id", property="noticeId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="notice_title", property="noticeTitle", jdbcType=JdbcType.VARCHAR),
        @Result(column="notice_content", property="noticeContent", jdbcType=JdbcType.VARCHAR),
        @Result(column="notice_create_admin_id", property="noticeCreateAdminId", jdbcType=JdbcType.INTEGER),
        @Result(column="notice_add_time", property="noticeAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="notice_update_time", property="noticeUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="notice_deleted", property="noticeDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallNotice selectByPrimaryKey(Integer noticeId);

    @UpdateProvider(type=HaogoumallNoticeSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallNotice record);

    @Update({
        "update haogoumall_notice",
        "set notice_title = #{noticeTitle,jdbcType=VARCHAR},",
          "notice_content = #{noticeContent,jdbcType=VARCHAR},",
          "notice_create_admin_id = #{noticeCreateAdminId,jdbcType=INTEGER},",
          "notice_add_time = #{noticeAddTime,jdbcType=TIMESTAMP},",
          "notice_update_time = #{noticeUpdateTime,jdbcType=TIMESTAMP},",
          "notice_deleted = #{noticeDeleted,jdbcType=BIT}",
        "where notice_id = #{noticeId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallNotice record);
}